#include "entity.h"
 
std::vector<Entity*> Entity::EntityList;
 
Entity::Entity() {
    surf_Entity = NULL;
 
    x = y = 0.0f;
    
    cellX = cellY = 0;
 
    width = height = 0;
    
    animState = 0;
}
 
Entity::~Entity() {
}
 
bool Entity::Load(char* File, int Width, int Height, int MaxFrames) {
    if((surf_Entity = Surface::Load(File)) == NULL) {
        return false;
    }
 
    Surface::SetTransparent(surf_Entity, 255, 0, 255);
 
    this->width = Width;
    this->height = Height;
    
    animCtrl.maxFrames = MaxFrames;
 
    return true;
}
 
void Entity::Loop() {
    animCtrl.Animate();
}
 
void Entity::Render(SDL_Surface* Surf_Display) {
    if(surf_Entity == NULL || Surf_Display == NULL) return;
 
    Surface::Draw(surf_Entity, animState * width, animCtrl.GetCurFrame() * height, width, height, Surf_Display, x, y);
}
 
void Entity::Cleanup() {
    if(surf_Entity) {
        SDL_FreeSurface(surf_Entity);
    }
 
    surf_Entity = NULL;
}